package com.example.userservice.aop;

import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class GlobalTransactionAspect {

    @Pointcut("@annotation(io.seata.spring.annotation.GlobalTransactional)")
    public void globalTransactionalPointcut() {
    }

    @AfterThrowing(value = "globalTransactionalPointcut()", throwing = "e")
    public void handleTransaction(Throwable e) {
        // 此处处理分布式事务异常
        throw new RuntimeException("分布式事务异常", e);
    }
}